<?
session_start();
$code_error="";
if(isset($_SESSION["code_error"]))
{
	$code_error = $_SESSION["code_error"];
	session_destroy();
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Administrator Login</title>
<script type="text/javascript">
	//ตรวจ keyCode ว่า กด enter หรือไม่ ถ้ากด enter แปลว่า คลิ๊กปุ่มล๊อกอิน
	function index_btnLogin_onKeypress(e){
		var evt=(e)?e:(window.event)?window.event:null; 
		if(evt)
		{ 
			var key=(evt.charCode)?evt.charCode: ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0)); 
			if(key=="13") 
				index_btnLogin();				
		}
	}
	function index_btnLogin()
	{
		if(document.getElementById("index_txtusername").value == "")
		{
			document.getElementById("codeUsernameError").innerHTML = "<BR><FONT COLOR=\"red\">Username is empty.</FONT>";
		}
		else
		{
			document.getElementById("codeUsernameError").innerHTML = "";
		}
		
		if(document.getElementById("index_txtpassword").value == "")
		{
			document.getElementById("codePasswordError").innerHTML = "<BR><FONT COLOR=\"red\">Password is empty.</FONT>";
		}
		else
		{
			document.getElementById("codePasswordError").innerHTML = "";
		}
		
		if(document.getElementById("index_txtusername").value != "" && document.getElementById("index_txtpassword").value != "")
		{
			document.getElementById("username").value = document.getElementById("index_txtusername").value;
			document.getElementById("password").value = document.getElementById("index_txtpassword").value;
			document.forms["formSubmit"].submit();
		}
	}
	function index_btnCancel()
	{
		document.getElementById("index_txtusername").value = "";
		document.getElementById("index_txtpassword").value = "";
	}
</script>
<style type="text/css">
body{ font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#797878;}
.username {

/* เซตภาพพื้นหลังให้กับ ช่องป้อนข้อมูล*/
background-image: url(images/login/group16.png);

/*ไม่ต้องรีพีต เดี๋ยวมันเป็นภาพเรียงซ้อนกันเต็ม ช่อง*/
background-repeat: no-repeat;

/*กั้นหน้าซะหน่อย เวลาพิมพ์ ตัวหนังสือจะได้ไม่ทับลงบนภาพพื้นหลัง*/
padding-left: 20px;
}
.password {
background-image: url(images/login/key.png);
background-repeat: no-repeat;
padding-left: 20px;

}
div.loginCenter
{ 
	margin-top:10%;
}
div.loginCenter td
{ font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#000;}
div.loginCenter a{ text-decoration:underline; font-size:10px; color:#7b7b7b }
div.logoSmile{ text-align:center;}

.borderSolid{ border:solid #963 10px;}

</style>
</head>

<body bgcolor="#f1f1f1" >


<div class="loginCenter">
	<table align="center"  bgcolor="#E1D3BB" class="borderSolid" >
	        <tr>
	          <td colspan="2" ><center><img src="images/login/smile_plus_logo.png" width="200" height="100"/></center></td>
	        </tr>
	        <tr>
	        	<td colspan="2" style="font-family:Tahoma, Geneva, sans-serif; font-size:14px;font-weight:bold; color:#000; text-align:center; " >  Login</td>
	        </tr>
	        <tr>
	            <td width="66"  align="right" valign="top">Username : </td>
	            <td width="165" ><input type="text" class="username" name="index_txtusername" id="index_txtusername" size="20" onKeypress="index_btnLogin_onKeypress(event)"/><div id="codeUsernameError"/></td>
	        </td>
	        </tr>
	        <tr>
		        <td align="right" valign="top">Password :</td>
		        <td><input type="password" class="password" name="index_txtpassword" id="index_txtpassword" size="20" onKeypress="index_btnLogin_onKeypress(event)"/><div id="codePasswordError"/></td>
	        </tr>
	        <tr>
		        <td></td>
		        <td><a href="#">ลืมรหัสผ่าน</a><?=$code_error;?></td>
	        </tr>
	        <tr>
		        <td align="right">&nbsp;</td>
		        <td>
		        	<button type="submit" onClick="index_btnLogin()"><img src="images/login/door_in.png" alt="" width="16" height="16" align="absmiddle" /> login</button>
		        	<button type="submit" onClick="index_btnCancel()"><img src="images/login/delete-small.png" alt="" width="16" height="16" align="absmiddle" /> cancle </button>
		        </td>
	        </tr>
	</table>
	<p><center><img src="images/login/forman_logo_200x53.jpg" width="150" height="40" /><br><br> &copy; 2011 For man tailor all rights reserved.</center></p>	
</div>
<form  action="command/login/login.php" name="formSubmit" method="post" >
	<input type="hidden" name="username" id="username"></input>
	<input type="hidden" name="password" id="password"></input>
</form>
</body>
</html>
